<?php
/*
* Author: Nguyen Hai Nam
* Plugin: BreadcrumbPlugin
* Desc	: Introduce pick.vn and sidle pic
* Date	: 12/12/2011
*/
class BreadcrumbPlugin extends Pick_Core_Plugin{
	
	function BreadcrumbPlugin(){
		parent::Pick_Core_Plugin();
		$this->namePlugin = "breadcrumb";
		$this->descriptionPlugin = "The plugin of each page at phone and";
	}
	public function getContent(){
		$breadcrum = array();
		$home['link'] = "/";
		$home['name'] = l('Home');
		array_push($breadcrum, $home);
		switch($this->op){
			case "aboutus":{
				$aboutus['link'] = "#";
				$aboutus['name'] = l('About-Us');	
				array_push($breadcrum, $aboutus);
				$statics = new Pick_Dao_Statics();
				$slug = $this->request->get('slug');
				if($slug){
					$objStatic = $statics->getObjectFromSlug($slug);
					array_push($breadcrum, array('link'=>$objStatic->getUrl($this->op), 'name'=>$objStatic->getFieldLang('name')));					
				}		
			}; break;
			case "contactus":{
				$contact['link'] = "#";
				$contact['name'] = l('Contact Us');	
				array_push($breadcrum, $contact);
			}; break;
			case "randd":{
				$aboutus['link'] = "#";
				$aboutus['name'] = l('R & D');
				array_push($breadcrum, $aboutus);
				$news = new Pick_Dao_News();
				$id = $this->request->get('id', '');
				$objNews = "";
				if($id){
					$objNews = $news->getObject($id);
					array_push($breadcrum, array('link'=>$objNews->getUrl($this->op), 'name'=>$objNews->getFieldLang('name')));					
				}	
			}; break;
			case "careers":{
				$careers['link'] = "#";
				$careers['name'] = l('Careers');	
				array_push($breadcrum, $careers);
				$news = new Pick_Dao_News();
				$id = $this->request->get('id', '');
				$objNews = "";
				if($id){
					$objNews = $news->getObject($id);
					array_push($breadcrum, array('link'=>$objNews->getUrl($this->op), 'name'=>$objNews->getFieldLang('name')));					
				}	
			}; break;
			case "newsmedia":{}
			case "newsmediadetail":{
				$newsmedia['link'] = "#";
				$newsmedia['name'] = l('News & Media');	
				array_push($breadcrum, $newsmedia);
				$newscategory = new Pick_Dao_NewsCategory();
				$news = new Pick_Dao_News();
				$id = $this->request->get('id', '');
				$objNews = "";
				if($this->op == "newsmedia" && $id){
					$objCategory = $newscategory->getObject($id);
					array_push($breadcrum, array('link'=>$objCategory->getUrl($this->op), 'name'=>$objCategory->getFieldLang('name')));					
				}	
				if($this->op == "newsmediadetail" && $id){
					$objNews = $news->getObject($id);
					array_push($breadcrum, array('link'=>$objNews->getUrl($this->op), 'name'=>$objNews->getFieldLang('name')));					
				}
			}; break;
			case "environment":{
				$aboutus['link'] = "#";
				$aboutus['name'] = l('Environment');
				array_push($breadcrum, $aboutus);
				$news = new Pick_Dao_News();
				$id = $this->request->get('id', '');
				$objNews = "";
				if($id){
					$objNews = $news->getObject($id);
					array_push($breadcrum, array('link'=>$objNews->getUrl($this->op), 'name'=>$objNews->getFieldLang('name')));					
				}	
			}; break;
			case "referenceprojects":{
				$aboutus['link'] = "#";
				$aboutus['name'] = l('Project References');
				array_push($breadcrum, $aboutus);
				$countries = new Pick_Dao_Countries();
				$id = $this->request->get('id', '');
				$objNews = "";
				if($id){
					$objNews = $countries->getObject($id);
					if(is_object($objNews))
						array_push($breadcrum, array('link'=>$objNews->getUrl($this->op), 'name'=>$objNews->getFieldLang('name')));					
				}	
			}; break;
			case "grouphistory":{
				$aboutus['link'] = "#";
				$aboutus['name'] = l('About Us');
				array_push($breadcrum, $aboutus);
				
				$grouphistory['link'] = "#";
				$grouphistory['name'] = l('Group History');
				array_push($breadcrum, $grouphistory);	
			}; break;
			case "productsub":{}
			case "product":{
				$product['link'] = "#";
				$product['name'] = l('Product');
				array_push($breadcrum, $product);
				
				$id = $this->request->get('id');
				$productcategory = new Pick_Dao_ProductCategory();
				$arrPath = $productcategory->getPathParrent($id);	
				foreach($arrPath as $objCat){
					if(is_object($objCat)){
						array_push($breadcrum, array('link'=>$objCat->getUrl('product'), 'name'=>$objCat->getFieldLang('name')));					
					}
				}
			}; break;
			default:{
				
			}; break;
		}
		$this->template->assign('breadcrum', $breadcrum);
	}
}